package com.stx.common;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Find {
    //返回去掉最高分和最低分的分数,最后的平均分
    public static Double getAvg(List<Double> list) {
        if (list.size() <= 2){
            return 0.0;
        }
        Collections.sort(list, new Comparator<Double>() {
            @Override
            public int compare(Double o1, Double o2) {
                return Double.compare(o1, o2);
            }
        });
        list.remove(0);
        list.remove(list.size()-1);
        double sum = 0;
        for (Double num : list) {
            sum =sum +num;
        }
        //返回最高分
        return sum / list.size();
    }
}
